<%@ page pageEncoding="UTF-8"%>
<%@ page trimDirectiveWhitespaces="true"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="isperp" uri="/WEB-INF/tlds/isperp.tld"%>

<%
	String path = request.getContextPath();
%>

<link rel="stylesheet" type="text/css" href="<%=path%>/css/profile.css" />

<script type="text/javascript">

function loginLogMenuTree_onNodeClick2(event, treeId,treeNode){
	
	if(treeNode.id=='1'){
		$("#loginSuccess").val("0")
	}else{

		$("#loginSuccess").val("1")
	}
	loginLogMenuTree_onNodeClick(event, treeId,treeNode);
}

function loginLogMenuTree_onNodeClickFirst() {
	var nodes=loginLogMenu.zTree.getNodes();
	if(nodes&&nodes[0]){node=nodes[0];}else{return;}
	loginLogMenu.zTree.selectNode(node);
	var postData = loginLogGrid.jqGrid.jqGrid("getGridParam", "postData");
	$.extend(postData, {queryPath:node.treenodePath});
	loginLogGrid.search();
}

</script>



<div class="grid_12 profile">
	<div class="header">
		<div class="title" style="padding:0px 10px 80px 120px">
			<h2>${currentUser.fullname }(${currentUser.name })</h2>
		</div>
		<div class="avatar">
			<c:choose>
				<c:when test="${empty currentUser.photo }">
					<img src="img/elements/profile/avatar.png">
				</c:when>
				<c:otherwise>
					<img src="${currentUser.photo  }"
						onclick="isperp.alert('<img src=\'${currentUser.photo  }\'>',{noIcon:true})">
				</c:otherwise>
			</c:choose>
			<a
				href="javascript:isperp.openDialog({id:'photoDialog',onThisWindow:true,windowSize:'normal', contentUrl:'app/user/photoEdit'});">修改</a>
		</div>
		<ul class="info">
			<li><a class="nui-txt-link" href="javascript:isperp.openDialog({contentUrl:'workflow/processRun/myTaskListView'});"
				class="open-profile-dialog"> <strong>${workflowTaskTotal
						}</strong> <small>代办事项</small> </a>
			</li>
			<li><a class="nui-txt-link"
				href="javascript:isperp.openDialog({contentUrl:'app/message/myMessageBoxView'});"
				class="open-profile-dialog"> <strong>${newMessageTotal
						}</strong> <small>新消息</small> </a>
			</li>
			<li><a class="nui-txt-link" href="javascript:isperp.openDialog({contentUrl:'knowledge/knowledgeItem/myKnowledgeView'});"
				class="open-profile-dialog"> <strong>${knowledgeTotal }</strong>
					<small>我的知识</small> </a>
			</li>
		</ul>
	</div>
</div>
<div class="details grid_6">
	<div class="header">
		<h2>个人信息</h2>
		<a class="nui-txt-link" href="javascript:openDialogChangeUserInfo();"><span
			class="icon icon-pencil"></span>修改个人信息</a>
	</div>
	<section>
		<table>
			<tbody>
				<tr>
					<th>姓名：</th>
					<td>${currentUser.fullname }</td>
				</tr>
				<tr>
					<th>Email：</th>
					<td>${currentUser.email }</td>
				</tr>
				<tr>
					<th>手机：</th>
					<td>${currentUser.mobile }</td>
				</tr>
				<tr>
					<th>出生日期：</th>
					<td><fmt:formatDate value="${currentUser.birthday }"
							pattern="yyyy-MM-dd" /></td>

				</tr>

			</tbody>
		</table>
	</section>
</div>
<div class="details grid_6">
	<div class="header">
		<h2>账户信息</h2>
		<a class="nui-txt-link" href="javascript:openDialogChangePwd();"><span
			class="icon icon-plus"></span>修改密码</a>
	</div>
	<section>
		<table>
			<tbody>
				<tr>
					<th>账户名：</th>
					<td>${currentUser.name }</td>
				</tr>
				<tr>
					<th>职位：</th>
					<td>${currentUser.title }</td>
				</tr>
				<tr>
					<th>所属部门：</th>
					<td>${departmentName }</td>
				</tr>
				<tr>
					<th>账户角色：</th>
					<td>${userRoles }</td>
				</tr>

			</tbody>
		</table>
	</section>
</div>


<isperp:grid url="app/loginLog/listByUsername" gridId="loginLogGrid"
	datatype="local" cusFormatterActions="false" gridTitle="登录日志"
	rowNum="10" sortorder="desc" sortname="createdDate" showSearchbar="true"
	afterGridCreate="loginLogMenuTree_onNodeClickFirst();">
	<jsp:attribute name="searchbar">
	<input type="hidden" value="0" id="loginSuccess" field="success"
			op="eq">
	</jsp:attribute>
	<jsp:attribute name="toolbar">
	<isperp:treeMenu id="loginLogMenu" targetGridId="loginLogGrid"
			nodes="[{id:1,name:'登录失败'},{id:2,name:'登录成功'}]">
		<isperp:async enable="false"></isperp:async>
		<isperp:data simpleData="true"></isperp:data>
		<isperp:callback onClick="loginLogMenuTree_onNodeClick2">
		</isperp:callback>
	</isperp:treeMenu>
	</jsp:attribute>
	<jsp:body>
	<isperp:column name="id" title="id" hidden="true"></isperp:column>

	<isperp:column name="ip" title="IP" width="80">
	</isperp:column>
	<isperp:column name="success" title="是否成功" formatter="checkbox" width="50">
	</isperp:column>
	<isperp:column name="createdDate" title="发生日期" width="100"
			sortable="true">
	 </isperp:column>
	<isperp:column name="info" title="信息" width="200">
	</isperp:column>
</jsp:body>
</isperp:grid>
<div class="clearfix"></div>
<div class="divider"></div>

<div id="dialogChangePwd" title="修改密码" style="display: none;">
	<form id="formChangePwd" action="app/user/changePassword"
		class="full validate">
		<table class="search-table" style="width:420px;margin:10px 5px">

			<tr>
				<td class="td1">现在的密码：</td>
				<td class="td2"><input id="oldPwd" class="required"
					type="password" name="oldPwd" />
				</td>
			</tr>

			<tr>
				<td class="td1">设置新的密码：</td>
				<td class="td2"><input type="password" id="newPwd"
					name="newPwd" class="required" minlength="6" maxlength="16" />
				</td>
			</tr>
			<tr>
				<td class="td1"></td>
				<td class="td2" style="vertical-align: top">
					<div class="info">6-16位，区分大小写，只能使用字母、数字、特殊字符</div></td>
			</tr>
			<tr>
				<td class="td1">重复新的密码：</td>
				<td class="td2"><input id="repeatNewPwd" type="password"
					class="required" equalTo="#newPwd" />
				</td>
			</tr>

		</table>

	</form>

</div>



<div id="dialogChangeUserInfo" title="修改个人信息" style="display: none;">
	<form id="formChangeUserInfo" action="app/user/changeUserInfo"
		class="full validate">

		<input type="hidden" name="id" value="${currentUser.id }" />
		<table class="search-table" style="width:420px;margin:10px 5px">

			<tr>
				<td class="td1">姓名：</td>
				<td class="td2"><input id="fullname" class="required"
					type="text" name="fullname" value="${currentUser.fullname }" />
				</td>
			</tr>

			<tr>
				<td class="td1">Email：</td>
				<td class="td2"><input type="text" name="email"
					class="required email" value="${currentUser.email }" />
				</td>
			</tr>
			<tr>
				<td class="td1">手机：</td>
				<td class="td2"><input type="text" name="mobile"
					class="required " value="${currentUser.mobile }" />
				</td>
			</tr>
			<tr>
				<td class="td1">出生日期：</td>
				<td class="td2"><input type="date" name="birthday"
					class="required date"
					value="<fmt:formatDate value="${currentUser.birthday }"
							pattern="yyyy-MM-dd" />" />
				</td>
			</tr>

		</table>

	</form>

</div>




<script>

    $("#loginLogGridAdToolbar button").hide();
	function openDialogChangePwd() {
		$("#dialogChangePwd").dialog("open");
	}

	$("#dialogChangePwd").dialog({
		autoOpen : false,
		resizable : false,
		width : 440,
		buttons : [ {
			text : "保存",
			"class" : "nui-mainbtn",
			click : function() {

				isperp.submitForm({
					formId : "formChangePwd",
					success : function(data, data2) {
						if (data && data.success == false) {
							isperp.warnAlart(data.data);
						} else {
							isperp.tooltip("密码修改成功！");

							$("#oldPwd").val("");
							$("#newPwd").val("");
							$("#repeatNewPwd").val("");

							$("#dialogChangePwd").dialog("close");
						}
					}
				});
			}
		},{ text : "关闭",
			click : function() {
				$(this).dialog("close");
			}
		
		}]
	});

	function openDialogChangeUserInfo() {
		$("#dialogChangeUserInfo").dialog("open");
	}

	$("#dialogChangeUserInfo").dialog({
		autoOpen : false,
		resizable : false,
		width : 440,
		buttons : [ {
			text : "保存",
			"class" : "nui-mainbtn",
			click : function() {

				isperp.submitForm({
					formId : "formChangeUserInfo",
					success : function(data, data2) {
						if (data && data.success == false) {
							isperp.warnAlert(data.data);
						} else {
							window.location.reload();
						}
					}
				});
			}
		} ,{ 
			text : "关闭",
			click : function() {
				$(this).dialog("close");
			}
		
		}]
	});
</script>
